package com.heima.common.aliyun;

import com.aliyun.imageaudit20191230.Client;
import com.aliyun.teaopenapi.models.Config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "aliyun")
public class Sample {

    private String accessKeyId;
    private String secret;
    private String scenes;

    /**
     * 使用AK&SK初始化账号Client
     * @return Client
     * @throws Exception
     */
    public Client createClient() throws Exception {
        Config config = new Config()
        // 必填，您的 AccessKey ID
        .setAccessKeyId(accessKeyId)
        // 必填，您的 AccessKey Secret
        .setAccessKeySecret(secret);
        // Endpoint 请参考 https://api.aliyun.com/product/imageaudit
        config.endpoint = "imageaudit.cn-shanghai.aliyuncs.com";
        return new Client(config);
    }

}
